﻿using System.Collections.ObjectModel;
using Ninject.Core.Parameters;
using TestBat.IModels.Models;
using TestBat.IViewModels.Base;
using TestBat.IViewModels.Workspaces.Results;
using TestBat.ServiceLocator;

namespace TestBat.ViewModels.Workspaces.Results
{
    public class ResultScheduleListViewModel : ListViewModel<IResultScheduleViewModel, ObservableCollection<IResultScheduleViewModel>>, IResultScheduleListViewModel
    {
        public ResultScheduleListViewModel(IScheduleModel scheduleModel)
            : base(false)
        {
            this.scheduleModel = scheduleModel;
        }

        protected override ObservableCollection<IResultScheduleViewModel> _RecreateItems()
        {
            ObservableCollection<IResultScheduleViewModel> list = new ObservableCollection<IResultScheduleViewModel>();

            foreach (var schedule in scheduleModel.GetAll())
            {
                IResultScheduleViewModel scheduleViewModel = DefaultServiceLocator.Get<IResultScheduleViewModel>(With.Parameters.ConstructorArgument("schedule", schedule));
                list.Add(scheduleViewModel);
            }

            return list;
        }

        private readonly IScheduleModel scheduleModel;
    }
}
